refactor: remove logger from install command#367
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #367 +/- ##
==========================================
- Coverage 65.24% 65.23% -0.01%
==========================================
Files 216 216
Lines 18026 17991 -35
==========================================
- Hits 11761 11737 -24
+ Misses 5176 5161 -15
- Partials 1089 1093 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mwbrooks
left a comment
There was a problem hiding this comment.
Comments for the reviewers eyes
| switch event.Name { | ||
| case "app_install_manifest": | ||
| // Ignore this event and format manifest outputs in create/update events | ||
| case "app_install_manifest_create": |
There was a problem hiding this comment.
note: You can search for any of the following event names to see that the output is now display where the event was previous broadcast:
app_install_manifest_createapp_install_manifest_updateapp_install_startapp_install_icon_successapp_install_icon_errorapp_install_complete
| } | ||
| log.Data["teamName"] = *authSession.TeamName | ||
|
|
||
| log.Info("on_apps_add_init") |
There was a problem hiding this comment.
note: This event name was broadcast but never subscribed anywhere 🤦🏻
| } | ||
|
|
||
| // addAppLocally will add the app to the project's apps file with an empty AppID, TeamID, etc | ||
| func addAppLocally(ctx context.Context, clients *shared.ClientFactory, log *logger.Logger, app types.App) (types.App, error) { |
There was a problem hiding this comment.
note: diff doesn't show that log *logger.Logger was removed.
|
|
||
| // addAppLocally will add the app to the project's apps file with an empty AppID, TeamID, etc | ||
| func addAppLocally(ctx context.Context, clients *shared.ClientFactory, log *logger.Logger, app types.App) (types.App, error) { | ||
| log.Info("on_apps_add_local") |
There was a problem hiding this comment.
note: Another event that was broadcast with no subscribers.
| return installState, types.App{}, slackerror.Wrap(err, slackerror.ErrAppAdd) | ||
| } | ||
|
|
||
| log.Info("on_apps_add_remote_success") |
There was a problem hiding this comment.
note: another event that was broadcast with no subscribers 😿
internal/pkg/apps/install.go
Outdated
| clients.IO.PrintInfo(ctx, false, "\n%s", style.Sectionf(style.TextSection{ | ||
| Emoji: "books", | ||
| Text: "App Manifest", | ||
| Secondary: []string{ | ||
| fmt.Sprintf(`Updated app manifest for "%s" in "%s"`, slackManifest.DisplayInformation.Name, *authSession.TeamName), | ||
| }, | ||
| })) |
There was a problem hiding this comment.
note: Example of replacing the event broadcast with the actual output.
| appManageURL := fmt.Sprintf("%s/apps", apiInterface.Host()) | ||
| log.Data["appURL"] = fmt.Sprintf("%s%s", appManageURL, app.AppID) | ||
| log.Data["appName"] = manifest.DisplayInformation.Name |
There was a problem hiding this comment.
note: appURL was never output anywhere.
| _, _ = clients.IO.WriteOut().Write([]byte("\n" + style.Sectionf(style.TextSection{ | ||
| Emoji: "books", | ||
| Text: "App Manifest", | ||
| Secondary: []string{ | ||
| fmt.Sprintf(`Updated app manifest for "%s" in "%s"`, slackManifest.DisplayInformation.Name, *authSession.TeamName), | ||
| }, | ||
| }))) |
There was a problem hiding this comment.
note: I'm using the identical clients.IO.WriteOut() syntax from cmd/ to avoid introducing formatting issues. The clients.IO.PrintInfo inserts newlines after the output, causing issues.
There was a problem hiding this comment.
🌟 praise: Good call for scoping this change!
👾 ramble: I'd be interested in standardizing formats to avoid these special cases. We've talked about this before and I think these changes bring us so much closer to these realities!
🗣️ note: Outputting from the internal package might also be something to avoid ongoing. Preferring cmd and perhaps composing commands might be another pattern to use if we find this continues to be a duplicated pattern here.
There was a problem hiding this comment.
👾 ramble: I'd be interested in standardizing formats to avoid these special cases. We've talked about this before and I think these changes bring us so much closer to these realities!
Agreed! While doing this work, I found myself thinking about how we can soon tackle improving our styling and formatting to avoid double-spaces. Hoping that comes soon!
🗣️ note: Outputting from the internal package might also be something to avoid ongoing. Preferring cmd and perhaps composing commands might be another pattern to use if we find this continues to be a duplicated pattern here.
I agree. I think a noble goal is to delete internal/pkg. The logic should either be moved to the command cmd/ or into reusable packages under internal/. This may naturally encourage output to be in cmd/.
| _, _ = clients.IO.WriteOut().Write([]byte("\n" + style.Sectionf(style.TextSection{ | ||
| Emoji: "books", | ||
| Text: "App Manifest", | ||
| Secondary: []string{ | ||
| fmt.Sprintf(`Updated app manifest for "%s" in "%s"`, slackManifest.DisplayInformation.Name, *authSession.TeamName), | ||
| }, | ||
| }))) |
There was a problem hiding this comment.
🌟 praise: Good call for scoping this change!
👾 ramble: I'd be interested in standardizing formats to avoid these special cases. We've talked about this before and I think these changes bring us so much closer to these realities!
🗣️ note: Outputting from the internal package might also be something to avoid ongoing. Preferring cmd and perhaps composing commands might be another pattern to use if we find this continues to be a duplicated pattern here.
| log.Info("app_install_manifest_update") | ||
| log.Info("on_update_app_install") |
There was a problem hiding this comment.
🪓 praise: This is so much easier for me to understand!
|
@zimeg Thanks again for taking the time to review this PR! These aren't exciting PRs to review or test, but I hope it leads to better code that's more enjoyable to work with. 🍵 |
Changelog
Summary
This pull request is part 3 of removing internal/logger package and is focused on the the
installcommand.Test Steps
Requirements